home *** CD-ROM | disk | FTP | other *** search
- Path: gambier.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Help referencing an array of strings
- Date: 5 Mar 1996 13:01:38 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hia3iINN4dn@gambier.ugrad.cs.ubc.ca>
- References: <313C7F02.5D54@interramp.com>
- NNTP-Posting-Host: gambier.ugrad.cs.ubc.ca
-
- In article <313C7F02.5D54@interramp.com>,
- James A. Clifton <jclifton@interramp.com> wrote:
- >I need to have an array of fixed-length strings in a structure.
- >The problem I am having is trying to reference a particular string
- >in the array:
- >
- >typedef struct ss {
- >/* some other data */
- >char sa[N][M];
- >} ss;
- >
- >ss s;
- >
- >Now how do I reference the Nth string???
- >
- >I know how to reference the Mth character in the Nth string:
- >
- >s.sa[n][m]
- >
- >But not the Nth entire string, I've tryed:
- >
- >s.sa[n][] and *s.sa[n] but neither works.
-
- Too bad you did not try a mere s.sa[n]. This is an array of M characters, which
- decays into a pointer; i.e. string. The locution &s.sa[n][0] will also work
- (address of the first character of string n).
-
- Are you making sure that the strings are zero-terminated, by the way?
- --
-
-